package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.entity.Inventory;
import com.example.springboot.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "http://localhost:7070")
@RestController
@RequestMapping("/Inventory")
public class InventoryController {

    @Autowired
    private InventoryService inventoryService;
    /**
     * 查询全部用户信息
     */
    @GetMapping("/selectAll")
    public Result selectAll() {
        List<Inventory> InventoryList = inventoryService.selectAll();
        return Result.success(InventoryList);
    }

    @GetMapping("/selectByid")
    public Result selectById(@RequestParam Long id) {
        List<Inventory> InventoryList = inventoryService.selectById(id);
        return Result.success(InventoryList);
    }

    @GetMapping("/selectByname")
    public Result selectByProductName(@RequestParam String name) {
        List<Inventory> InventoryList = inventoryService.selectByProductName(name);
        return Result.success(InventoryList);
    }

    @GetMapping("/selectBycategory")
    public Result selectByCategory(@RequestParam String category) {
        List<Inventory> InventoryList = inventoryService.selectByCategory(category);
        return Result.success(InventoryList);
    }

    @GetMapping("/selectBybrand")
    public Result selectByBrand(@RequestParam String brand) {
        List<Inventory> InventoryList = inventoryService.selectByBrand(brand);
        return Result.success(InventoryList);
    }

    @GetMapping("/selectBysupplier")
    public Result selectBySupplier(@RequestParam String supplier) {
        List<Inventory> InventoryList = inventoryService.selectBySupplier(supplier);
        return Result.success(InventoryList);
    }



}